angular.module('mvcApp.change-password', [
    'ngRoute',
    'ngResource'
]).config(['$routeProvider', function ($routeProvider) {
    $routeProvider
        .when('/change-password', {
            templateUrl: 'static/views/change-password.html',
            controller: 'ChangePasswordCtrl'
        });
}]).controller('ChangePasswordCtrl', ['$scope', '$rootScope', '$http', '$location', 'User', '$routeParams', 'Shop', 'Category', 'Product',
    function ($scope, $rootScope, $http, $location, User, $routeParams, Shop, Category, Product) {
        $scope.changePassword = function (password, repeatPassword) {
            if (password !== repeatPassword) {
                alert("两次密码不一致");
                return;
            }
            User.changePassword(password)
                .then(function (userInfo) {
                    alert("修改密码成功");
                }).catch(function (err) {
                    alert(err);
                });
        };
    }]);